﻿using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.UnitCommand;
using MediatR;
using Microsoft.AspNetCore.Connections;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.UnitCommandHandler
{
    public class UnitCityCommandHandler : IRequestHandler<UnitCityCommand, Results<List<City>>>
    {

        private readonly IUnitService unitService;
        private readonly ILogger<UnitCityCommandHandler> logger;
        public UnitCityCommandHandler(IUnitService unitService, ILogger<UnitCityCommandHandler> logger)
        {
            this.unitService = unitService;
            this.logger = logger;
        }



        /// <summary>
        /// 市列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<Results<List<City>>> Handle(UnitCityCommand request, CancellationToken cancellationToken)
        {
            var userInfo = await unitService.CityList
                (request.ProVinceId);
            return Results<List<City>>.DataResult(userInfo);

        }




    }




}
